package com.erp.module.storesRequisitionPackage

import android.content.Context
import com.erp.Interface.OnUserDataInterface
import com.erp.contacts.Contacts
import com.erp.util.Httputil
import com.erp.util.Myutil
import org.xutils.http.RequestParams
import org.xutils.x

class SrpModel {
    private val CREATE_PACKAGE = Contacts.HTTP + "/lv/storesRequisition/package" //上传打包
    private val GET_PACKAGE = Contacts.HTTP + "/lv/storesRequisition/package" //获取打包数据
    /**上传打包数据 */
    fun setPcakage(context: Context, scanList : MutableList<String>, onUserDataInterface: OnUserDataInterface) {
        val params = RequestParams(CREATE_PACKAGE)
        for (i in 0 until scanList.count()){
            Myutil.Mylog("TAAG",scanList[i])
            params.addBodyParameter("stores_requisition_codes[$i]",scanList[i])
        }
        Httputil.getparams(context, params)
        x.http().post<String>(params, Httputil.Call(context, onUserDataInterface))
    }

    fun getPcakage(context: Context, code : String, onUserDataInterface: OnUserDataInterface) {
        val params = RequestParams("$GET_PACKAGE/$code")

        Httputil.getparams(context, params)
        x.http().get<String>(params, Httputil.Call(context, onUserDataInterface))
    }
}